<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminRolePermissionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admins', function (Blueprint $table) {
            $table->increments('id');
            $table->string('account');
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

        Schema::create("roles", function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('description');
            $table->timestamps();
        });

        Schema::create("permissions", function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('description');
            $table->timestamps();
        });

        Schema::create("admin_role", function (Blueprint $table) {
            $table->increments('id');
            $table->integer("role_id");
            $table->integer("admin_id");
        });

        Schema::create("role_permission", function (Blueprint $table) {
            $table->increments('id');
            $table->integer("role_id");
            $table->integer("permission_id");
        });


    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admins');
        Schema::dropIfExists('roles');
        Schema::dropIfExists('permissions');
        Schema::dropIfExists('admin_role');
        Schema::dropIfExists('role_permission');
    }
}
